<template>
  <div class="mine">
    <div class="card">
      <div class="top">
        <img class="avator" crossorigin="anonymous" :src="userInfo.headImgUrl" alt="" />
        <div class="right">
          <div class="user-name">
            <span>{{ userInfo.nickname }}</span>
            <img src="@assets/images/icon_auth.png" alt="" />
          </div>
          <div class="company-name" v-show="userInfo.company">
            <span>{{ userInfo.company }}</span>
            <span class="van-hairline--surround">{{ userInfo.identityType === 1 ? '法人' : userInfo.identityType === 2 ? '财务' : '销售' }}</span>
          </div>
        </div>
      </div>
      <ul class="bottom">
        <li>
          <img src="@assets/images/tel.png" alt="" />
          <span>{{ userInfo.phone }}</span>
        </li>
        <li v-show="userInfo.address">
          <img src="@assets/images/location.png" alt="" />
          <span>{{ userInfo.address }}</span>
        </li>
      </ul>
    </div>
    <ul class="cell-list">
      <li v-for="(item, index) in cellList" :key="index" :class="index > 0 ? 'van-hairline--top' : ''" @click="routerTo(item.link)">
        <img :src="item.img" alt="" />
        <span>{{ item.title }}</span>
      </li>
    </ul>
  </div>
</template>

<script>
import html2canvas from 'html2canvas';
import { Button, Toast, Field, Dialog } from 'vant';
import { user_updateUser } from '@api/user';
export default {
  components: {
    'van-button': Button,
    'van-field': Field
  },
  data() {
    return {
      address: '',
      cellList: [
        {
          title: '修改资料',
          img: require('@assets/images/mine_icon05.png'),
          link: '/userInfo'
        },
        {
          title: '我的订单',
          img: require('@assets/images/mine_icon06.png'),
          link: '/myOrder'
        },
        {
          title: '我的商机',
          img: require('@assets/images/mine_icon02.png'),
          link: '/collectBussiness'
        },
        {
          title: '名片列表',
          img: require('@assets/images/card_icon.png'),
          link: '/cardList'
        },
        {
          title: '专属顾问',
          img: require('@assets/images/mine_icon03.png'),
          link: '/consultant'
        },
        {
          title: '发票抬头',
          img: require('@assets/images/mine_icon01.png'),
          link: '/invoiceList'
        }
      ]
    };
  },
  created() {
    if (!this.token) {
      Dialog.confirm({
        title: '您还未实名，是否立即进行实名',
        confirmButtonColor: '#f09637',
        confirmButtonText: '立即实名',
        cancelButtonText: '暂不实名'
      }).then(() => {
        this.$router.openPage('/login');
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.mine {
  background: url('../../assets/images/mine_bg.png') no-repeat top;
  background-size: contain;
  padding: 50px 33px 130px;
  box-sizing: border-box;
}
.card {
  width: 100%;
  position: relative;
  height: 364px;
  background-image: linear-gradient(to bottom right, #f9e6ce, #ecbf8e);
  border-radius: 12px;
  font-size: 24px;
  padding: 62px 30px 0;
  color: #53360e;
  overflow: hidden;
  box-sizing: border-box;
  .top {
    display: flex;
    align-items: center;
  }
  .avator {
    width: 93px;
    height: 93px;
    border-radius: 50%;
    margin-right: 23px;
  }
  .user-name {
    display: flex;
    align-items: center;
    font-size: 32px;
    font-weight: bold;
    img {
      width: 184px;
      height: 36px;
      margin-left: 23px;
    }
  }
  .company-name {
    margin-top: 15px;
    span:last-child {
      display: inline-block;
      padding: 6px 16px;
      border-radius: 16px;
      font-size: 22px;
      margin-left: 15px;
      &:after {
        border-color: #53360e;
        border-radius: 32px;
      }
    }
  }
  .bottom {
    margin-top: 76px;
    li {
      display: flex;
      align-items: center;
      margin-bottom: 16px;
    }
    img {
      width: 20px;
      margin-right: 20px;
    }
  }
  .qrcode {
    position: absolute;
    right: 31px;
    bottom: 28px;
    width: 38px;
    height: 38px;
  }
}
.cell-list {
  background: #fff;
  padding: 0 30px;
  border-radius: 16px;
  margin-top: 50px;
  box-shadow: 0px 5px 18px 0px rgba(41, 47, 61, 0.08);
  li {
    position: relative;
    height: 100px;
    display: flex;
    align-items: center;
    font-size: 26px;
    color: #292f3d;
    img {
      width: 25px;
      margin-right: 24px;
    }
    &:before {
      content: '';
      position: absolute;
      right: 10px;
      top: 50%;
      margin-top: -12px;
      width: 12px;
      height: 23px;
      background: url('../../assets/images/arrow_right.png') no-repeat top;
      background-size: cover;
    }
  }
}
</style>
